//
//  BaseTableViewCell.m
//  WTGesturePassword
//
//  Created by 谢英泽 on 16/11/11.
//  Copyright © 2016年 谢英泽. All rights reserved.
//

#import "BaseTableViewCell.h"
#import <Masonry.h>
#import "AppHeader.h"


@interface BaseTableViewCell ()

@property (nonatomic, strong) UIView *lineView;

@end

@implementation BaseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self initData];
        
        [self initSubView];
        [self autoLayoutSubviews];
        
        [self bindViewModel];
    }
    return self;
}

#pragma mark - 配置RAC信号发送
/**
 绑定数据
 */
- (void)initData{}

#pragma mark - 基本方法

- (void)bindViewModel{}

/**
 添加控件
 */
- (void)initSubView{}

/**
 布局
 */
- (void)autoLayoutSubviews{}

#pragma mark - 设置样式

/**
 是否设置箭头
 
 @param isShowArrow 是否显示箭头
 */
- (void)setIsShowArrow:(BOOL)isShowArrow
{
    if (isShowArrow) {
        //箭头
        UIImageView *arrowImageView = [UIImageView new];
        arrowImageView.image = [UIImage imageNamed:@"wd_unity_rightArrow"];
        [self addSubview:arrowImageView];
        
        [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-kUI_MarginW * 2));
            make.centerY.equalTo(@0);
            make.width.equalTo(@15.f);
            make.height.equalTo(@15.f);
        }];
    }
}

- (void)setCellLineType:(kCellLineType)cellLineType
{
    _cellLineType = cellLineType;
    
    if (_cellLineType == kCellLineTypeNone) {
        return;
    }else if (_cellLineType == kCellLineTypeNormal){
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = kCOLOR_RGBValue(0xeaeaea);
        self.lineView = lineView;
        [self addSubview:lineView];
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            make.right.bottom.equalTo(@0);
            make.height.equalTo(@0.5);
        }];
    }else{
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = kCOLOR_RGBValue(0xeaeaea);
        self.lineView = lineView;
        [self addSubview:lineView];
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(@0);
            make.height.equalTo(@0.5);
        }];
    }
}

- (void)setMarginLeft:(CGFloat)left right:(CGFloat)right
{
    [self.lineView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(left));
        make.right.equalTo(@(right));
    }];
}

@end
